/*
 * Copyright (C) 2023 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
pub fn usage() -> String {
    "                         OpenHarmony device connector(HDC) ... \n".to_string()
            + "---------------------------------global commands:---------------------------------- \n"
            + " -h/help [verbose]                     - Print hdc help, 'verbose' for more other cmds \n"
            + " -v/version                            - Print hdc version \n"
            + " -t CONNECTKEY                         - Use device with given connect key \n"
            + "---------------------------------component commands:------------------------------- \n"
            + "session commands(on server): \n"
            + " list targets [-v]                     - List all devices status, '-v' to display details \n"
            + " start [-r]                            - Start server. '-r' to restart server \n"
            + " kill [-r]                             - Kill server. '-r' to restart server \n"
            + "service commands(on daemon): \n"
            + " target mount                          - Set /system /vendor partition read-write \n"
            + " target boot [-bootloader|-recovery]   - Reboot the device or boot into bootload / recovery. \n"
            + " smode [-r]                            - Restart daemon with root permissions, '-r' to cancel \n"
            + "                                         root permissions \n"
            + " tmode usb                             - Reboot the device, listening on USB \n"
            + " tmode port [PORT]                     - Reboot the device, listening on TCP port \n"
            + "---------------------------------task commands:------------------------------------- \n"
            + "file commands: \n"
            + " file send [OPTION] LOCAL REMOTE       - Send file to device \n"
            + " file recv [OPTION] REMOTE LOCAL       - Recv file from device \n"
            + "                                         options are -a|-s|-z \n"
            + "                                         -a: hold target file timestamp \n"
            + "                                         -sync: just update newer file \n"
            + "                                         -z: compress transfer \n"
            + "                                         -m: mode sync \n"
            + "forward commands: \n"
            + " fport LOCALNODE REMOTENODE            - Forward local traffic to remote device \n"
            + " rport REMOTENODE LOCALNODE            - Reserve remote traffic to local host \n"
            + "                                         node config name format 'schema:content' \n"
            + "                                         examples are below: \n"
            + "                                         tcp:<port> \n"
            + "                                         localfilesystem:<unix domain socket name> \n"
            + "                                         localreserved:<unix domain socket name> \n"
            + "                                         localabstract:<unix domain socket name> \n"
            + "                                         dev:<device name> \n"
            + "                                         jdwp:<pid> (remote only) \n"
            + " fport ls                              - Display forward/reverse tasks \n"
            + " fport rm TASK                         - Remove forward/reverse TASK \n"
            + "app commands: \n"
            + " install [-r|-s] PACKAGE               - Send package(s) to device and install them \n"
            + "                                         src examples: single or multiple packages and \n"
            + "                                         directories (.hap .hsp) \n"
            + "                                         -r: replace existing application \n"
            + "                                         -s: install shared bundle for multi-apps \n"
            + " uninstall [-k] [-s] PACKAGE           - Remove application package from device \n"
            + "                                         -k: keep the data and cache directories \n"
            + "                                         -s: remove shared bundle \n"
            + "debug commands: \n"
            + " hilog [-h]                            - Show device log, '-h' to display details \n"
            + " shell [COMMAND...]                    - Run shell command, \n"
            + "                                         interactive shell if no command given \n"
            + " bugreport [FILE]                      - Return all information from the device, \n"
            + "                                         stored in file if FILE is specified \n"
            + " jpid                                  - List pids of processes hosting a JDWP transport \n"
            + "security commands: \n"
            + " keygen FILE                           - Generate public/private key; \n"
            + "                                         key stored in FILE and FILE.pub \n"
}

pub fn verbose() -> String {
    let mut s = "                         OpenHarmony device connector(HDC) ... \n".to_string()
            + "---------------------------------global commands:---------------------------------- \n"
            + " -h/help [verbose]                     - Print hdc help, 'verbose' for more other cmds \n"
            + " -v/version                            - Print hdc version \n"
            + " -l[0-5]                               - Set runtime loglevel \n"
            + " -t connectkey                         - Use device with given connect key \n"
            + " checkserver                           - check client-server version \n"
            + " checkdevice                           - check server-daemon version(only uart) \n"
            + " \n"
            + "---------------------------------component commands:------------------------------- \n"
            + "session commands(on server): \n"
            + " discover                              - Discover devices listening on TCP via LAN broadcast \n"
            + " list targets [-v]                     - List all devices status, '-v' to display details \n"
            + " tconn key                             - Connect device via key, TCP use IP:PORT \n"
            + "                                         example:192.168.0.100:10178 \n"
            + "                                         USB connect automatic. \n"
            + "                                         TCP need to connect manually. \n";
    if cfg!(HDC_SUPPORT_UART) {
        s = s
            + "                                         UART connect need connect manually. \n"
            + "                                         Baud Rate can be specified with commas. \n"
            + "                                         key format: PORTNAME[,BAUDRATE] \n"
            + "                                         example: tconn COM5,921600 \n"
            + "                                         Default Baud Rate is 921600. \n"
    }
    s
            + " start [-r]                            - Start server. '-r' to restart server \n"
            + " kill [-r]                             - Kill server. '-r' to restart server \n"
            + " -s [ip:]port                          - Set hdc server listen config \n"
            + " \n"
            + "service commands(on daemon): \n"
            + " target mount                          - Set /system /vendor partition read-write \n"
            + " target boot [-bootloader|-recovery]   - Reboot the device or boot into bootloader / recovery. \n"
            + " smode [-r]                            - Restart daemon with root permissions, '-r' to cancel \n"
            + "                                         root permissions \n"
            + " tmode usb                             - Reboot the device, listening on USB \n"
            + " tmode port [PORT]                     - Reboot the device, listening on TCP port \n"
            + " \n"
            + "---------------------------------task commands:------------------------------------- \n"
            + "file commands: \n"
            + " file send [OPTION] LOCAL REMOTE       - Send file to device \n"
            + " file recv [OPTION] REMOTE LOCAL       - Recv file from device \n"
            + "                                         options are -a|-s|-z \n"
            + "                                         -a: hold target file timestamp \n"
            + "                                         -sync: just update newer file \n"
            + "                                         -z: compress transfer \n"
            + "                                         -m: mode sync \n"
            + " \n"
            + "forward commands: \n"
            + " fport LOCALNODE REMOTENODE            - Forward local traffic to remote device \n"
            + " rport REMOTENODE LOCALNODE            - Reserve remote traffic to local host \n"
            + "                                         node config name format 'schema:content' \n"
            + "                                         examples are below: \n"
            + "                                         tcp:<port> \n"
            + "                                         localfilesystem:<unix domain socket name> \n"
            + "                                         localreserved:<unix domain socket name> \n"
            + "                                         localabstract:<unix domain socket name> \n"
            + "                                         dev:<device name> \n"
            + "                                         jdwp:<pid> (remote only) \n"
            + " fport ls                              - Display forward/reverse tasks \n"
            + " fport rm TASK                         - Remove forward/reverse TASK \n"
            + " \n"
            + "app commands: \n"
            + " install [-r|-s] PACKAGE               - Send package(s) to device and install them \n"
            + "                                         src examples: single or multiple packages and \n"
            + "                                         directories (.hap .hsp) \n"
            + "                                         -r: replace existing application \n"
            + "                                         -s: install shared bundle for multi-apps \n"
            + " uninstall [-k] [-s] PACKAGE           - Remove application package from device \n"
            + "                                         -k: keep the data and cache directories \n"
            + "                                         -s: remove shared bundle \n"
            + " \n"
            + "debug commands: \n"
            + " hilog [-h]                            - Show device log, '-h' to display details \n"
            + " shell [COMMAND...]                    - Run shell command, \n"
            + "                                         interactive shell if no command given \n"
            + " bugreport [FILE]                      - Return all information from the device, \n"
            + "                                         stored in file if FILE \n"
            + "is specified \n"
            + " jpid                                  - List pids of processes hosting a JDWP transport \n"
            + " sideload [PATH]                       - Sideload the given full OTA package \n"
            + " \n"
            + "security commands: \n"
            + " keygen FILE                           - Generate public/private key; \n"
            + "                                         key stored in FILE and FILE.pub \n"
            + " \n"
            + "---------------------------------flash commands:------------------------------------ \n"
            + "flash commands: \n"
            + " update packagename                    - Update system by package \n"
            + " flash [-f] PARTITION IMAGE            - Flash partition by image \n"
            + " erase [-f] PARTITION                  - Erase partition \n"
            + " format [-f] PARTITION                 - Format partition \n"
}
